home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / owlbwcc.zip / BWCKALL.CPP < prev    next >
C/C++ Source or Header  |  1992-02-02  |  7KB  |  168 lines

  1. /**********************************************************************/
  2. /*                  BWCKALL.cpp by Bob Bourbonnais                    */
  3. /*              released to the public domain 2/02/92                 */
  4. /*          This program shows how to switch to different             */
  5. /*            routines based on the button pressed using              */
  6. /*              Dynamic Dispatched Virtual Tables, DDVT               */
  7. /*      It also shows how to use pointers to BWCC check boxes         */
  8. /*           to show the ON/OFF status of the check boxes             */
  9. /*        and to set the initial state via the check command          */
  10. /*         It demonstrates immediate and delayed processing.          */
  11. /**********************************************************************/
  12. #include <owl.h>
  13. #include <dialog.h>
  14. #include "bwcc.h"                        // needed for BWCC
  15. #include "bchkbox.h"                     // needed for BWCC checkboxs
  16. #include "BWCKALL.H"                     // equates for checkboxes
  17.  
  18. class TMyDialog : public TDialog
  19.   {
  20.   public:
  21.     TBCheckBox *pcbRadar12, *pcbConfabulator12,  // pointers to check boxes
  22.            *pcbRadar13, *pcbConfabulator13;
  23.     TMyDialog(LPSTR lpDialogName);              // constructor
  24.  
  25.     virtual void SetupWindow();  // SetupWindow is called after dialog box
  26.                  // is created and is used for initialization
  27.                  // of controls.
  28.     virtual void Ok(RTMessage Msg);        // redefines the DDVT function
  29.                        // for the OK button #1
  30.                        // as defined in Base class
  31.                        // TDialog
  32.  
  33.     virtual void HandleRadar12(RTMessage Msg)  // these DDVT toggles
  34.       = [ID_FIRST + IDB_RADAR12];              // activate immediately
  35.     virtual void HandleConfabulator12(RTMessage Msg) // like regular
  36.       = [ID_FIRST + IDB_CONFABULATOR12];             // buttons
  37.  
  38.     virtual void DefChildProc(RTMessage Msg); // default button handler
  39.   };
  40.  
  41. void TMyDialog::TMyDialog(LPSTR lpDialogName)  // constructor calls
  42.           : TDialog(NULL,lpDialogName)     // base class constructor
  43.   {
  44.   BWCCGetVersion();    // activate Borland Windows Custom Controls
  45.  
  46.   pcbRadar12 = new TBCheckBox(this,IDB_RADAR12,NULL);    //links up
  47.   pcbConfabulator12 = new TBCheckBox(this,               //pointers
  48.                      IDB_CONFABULATOR12, //to check boxes
  49.                      NULL);              //That were made
  50.   pcbRadar13 = new TBCheckBox(this,IDB_RADAR13,NULL);    //in the .RC
  51.   pcbConfabulator13 = new TBCheckBox(this,               //via the
  52.                      IDB_CONFABULATOR13, //workshop
  53.                      NULL);
  54.   }
  55.  
  56. void TMyDialog::SetupWindow()    // called after dialog box is displayed
  57.   {
  58.   TDialog::SetupWindow();        // call base class set up
  59.   pcbRadar13->Check();           // check Radar13 and Confabulator13
  60.   pcbConfabulator13->Check();
  61.   }
  62.  
  63. void TMyDialog::Ok(RTMessage Msg)  // Redefines button handler inherited
  64.   {                                // from TDailog for Button #1 IDOK
  65.   char szMyString[180];
  66.  
  67.   if (pcbRadar13->GetCheck()==BF_CHECKED)           // find out the ON/OFF
  68.     {                                               // status
  69.     lstrcpy(szMyString,"Radar Unit 13 is Activated.\n");
  70.     }
  71.   else
  72.     {
  73.     lstrcpy(szMyString,"Radar Unit 13 is Shutdown.\n");
  74.     }
  75.  
  76.   if (pcbConfabulator13->GetCheck()==BF_CHECKED)           // find out the ON/OFF
  77.     {
  78.     lstrcat(szMyString,"The Confabulator on Unit 13 is Activated.");
  79.     }
  80.   else
  81.     {
  82.     lstrcat(szMyString,"The Confabulator on Unit 13 is OFF.");
  83.     }
  84.  
  85.   BWCCMessageBox(HWindow,szMyString,"Update on Unit #13",MB_OK); //output
  86.                                  //status
  87.   TDialog::Ok(Msg);     //default OK handler to close dialog box
  88.   }
  89.  
  90. void TMyDialog::HandleRadar12(RTMessage)            // immediately
  91.   {
  92.   if (pcbRadar12->GetCheck()==BF_CHECKED)           // find out the ON/OFF
  93.     {                                               // status of the checkbox
  94.                             // using a pointer to the
  95.                             // checkbox
  96.     MessageBeep(0);                                 // if we turned it on
  97.     BWCCMessageBox(HWindow,"Radar Unit 12 Activated", // beep and display
  98.                "ACTIVATION!",MB_OK);      // message box
  99.     }
  100.   else                                              // if we turned it off
  101.     {
  102.     MessageBeep(0);                                 // beep and display a
  103.     BWCCMessageBox(HWindow,"Radar Unit 12 OFF",     // different message
  104.                "SHUTDOWN!",MB_OK);
  105.     }
  106.   }
  107.  
  108. void TMyDialog::HandleConfabulator12(RTMessage)     // Same for second
  109.   {                                                 // Item
  110.   if (pcbConfabulator12->GetCheck()==BF_CHECKED)
  111.     {
  112.     MessageBeep(0);
  113.     BWCCMessageBox(HWindow,"Confabulator on Unit 12 Activated",
  114.                "ACTIVATION!",MB_OK);
  115.     }
  116.   else
  117.     {
  118.     MessageBeep(0);
  119.     BWCCMessageBox(HWindow,"Confabulator on Unit 12 OFF",
  120.                "SHUTDOWN!",MB_OK);
  121.     }
  122.   }
  123.  
  124. void TMyDialog::DefChildProc(RTMessage Msg)   // default button handler
  125.   {
  126.   if ((Msg.WParam == IDB_RADAR13)|(Msg.WParam == IDB_CONFABULATOR13))
  127.     {          // If either of the unit #13 buttons are pressed then
  128.     TDialog::DefChildProc(Msg);  // pass message along to base class
  129.     }                            // to check the box
  130.   else
  131.     {
  132.     MessageBeep(0);                             // make sound and display
  133.     BWCCMessageBox(HWindow,"Not Implemented",   // a BWCC message box
  134.           "Feature",MB_OK);
  135.     TDialog::DefChildProc(Msg);                 // pass messages along
  136.     }                                           // to base class handler
  137.   }
  138.  
  139. class TDialog1App : public TApplication  // Application Class to contain
  140.   {                                      // the application
  141.   public:
  142.     TDialog1App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  143.         HANDLE hPrevInstance,            // base class constructor
  144.         LPSTR lpCmdLine, int nCmdShow)
  145.         :TApplication(lpName, hInstance,
  146.                   hPrevInstance,
  147.                   lpCmdLine, nCmdShow) {};
  148.  
  149.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  150.   };
  151.  
  152. void TDialog1App::InitMainWindow() // to initialize a dialog box
  153.   {                                // as the main window
  154.   MainWindow = new TMyDialog("MAINWINDOWDIALOG");
  155.   }
  156.  
  157. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  158.            HANDLE hPrevInstance,          // windows to this program
  159.            LPSTR lpCmdLine , int nCmdShow)
  160.   {
  161.   TDialog1App Dialog1("Dialog Tester",hInstance,  // create instance of
  162.                hPrevInstance,             // the dialog application
  163.                lpCmdLine,nCmdShow);
  164.   Dialog1.Run();                                  // run it
  165.   return (Dialog1.Status);                        // exit
  166.   }
  167. /**********************************************************************/
  168.